package com.ruoyi.tsjData.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.tsjData.domain.plat.DataTshjTyxn;
import com.ruoyi.tsjData.domain.plat.DataTshjTyxnModify;
import com.ruoyi.tsjData.service.IDataTshjTyxnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提升机-调压性能测试Controller
 * 
 * @author ruoyi
 * @date 2023-10-25
 */
@RestController
@RequestMapping("/tsjData/tyxn")
@Api(value="提升机-调压性能测试",tags = "提升机-调压性能测试接口")
public class DataTshjTyxnController extends BaseController
{
    @Autowired
    private IDataTshjTyxnService dataTshjTyxnService;

    /**
     * 查询提升机-调压性能测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:tyxn:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataTshjTyxn dataTshjTyxn)
    {
        startPage();
        List<DataTshjTyxn> list = dataTshjTyxnService.selectDataTshjTyxnList(dataTshjTyxn);
        return getDataTable(list);
    }

    /**
     * 导出提升机-调压性能测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:tyxn:export')")
    @Log(title = "提升机-调压性能测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataTshjTyxn dataTshjTyxn)
    {
        List<DataTshjTyxn> list = dataTshjTyxnService.selectDataTshjTyxnList(dataTshjTyxn);
        ExcelUtil<DataTshjTyxn> util = new ExcelUtil<DataTshjTyxn>(DataTshjTyxn.class);
        util.exportExcel(response, list, "提升机-调压性能测试数据");
    }

    /**
     * 获取提升机-调压性能测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('tsjData:tyxn:query')")
    @GetMapping(value = "/{tyxnId}")
    public AjaxResult getInfo(@PathVariable("tyxnId") Long tyxnId)
    {
        return success(dataTshjTyxnService.selectDataTshjTyxnByTyxnId(tyxnId));
    }

    /**
     * 新增提升机-调压性能测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:tyxn:add')")
    @Log(title = "提升机-调压性能测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataTshjTyxn dataTshjTyxn)
    {
        return toAjax(dataTshjTyxnService.insertDataTshjTyxn(dataTshjTyxn));
    }

    /**
     * 根据调压性能id获取油压差
     * @param tyxn1
     * @param tyxn2
     * @return
     */
    @PreAuthorize("@ss.hasPermi('tsjData:getTyxnYycha:query')")
    @GetMapping(value = "/getTyxnYycha/{tyxn1}/{tyxn2}")
    @ApiOperation(value="根据调压性能id获取油压差")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "tyxn1", value = "油压1id", required = true, dataType = "Long"),
            @ApiImplicitParam(paramType="query", name = "tyxn2", value = "油压2id", required = true, dataType = "Long"),
    })
    public Map<String, Object> getTyxnYycha(@PathVariable("tyxn1")Long tyxn1, @PathVariable("tyxn2")Long tyxn2) {
        return AjaxResult.success(dataTshjTyxnService.getTyxnYycha(tyxn1, tyxn2));
    }

    /**
     * 根据调压性能id获取前后段油压曲线
     * @param tyxn1
     * @param tyxn2
     * @return
     */
    @PreAuthorize("@ss.hasPermi('tsjData:getTshjTyxnJs:query')")
    @GetMapping(value = "/getTshjTyxnJs")
    @ApiOperation(value="根据调压性能id获取前后段油压曲线")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "tyxn1", value = "油压1id", required = false, dataType = "Long"),
            @ApiImplicitParam(paramType="query", name = "tyxn2", value = "油压2id", required = false, dataType = "Long"),
    })
    public Map<String, Object> getTshjTyxnJs(@RequestParam(value = "tyxn1", required = false)Long tyxn1, @RequestParam(value = "tyxn2", required = false)Long tyxn2) {
        return AjaxResult.success(dataTshjTyxnService.getTshjTyxnJs(tyxn1, tyxn2));
    }

    /**
     * 修改提升机-调压性能测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:tyxn:edit')")
    @Log(title = "提升机-调压性能测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataTshjTyxn dataTshjTyxn)
    {
        return toAjax(dataTshjTyxnService.updateDataTshjTyxn(dataTshjTyxn));
    }

    /**
     * 修改提升机-调压性能测试曲线图
     */
    @PreAuthorize("@ss.hasPermi('tsjData:tyxn:editChart')")
    @Log(title = "提升机-调压性能测试曲线图", businessType = BusinessType.UPDATE)
    @PostMapping("/editChart")
    @ApiOperation(value="修改提升机-调压性能测试曲线图")
    public AjaxResult editChart(@RequestBody List<DataTshjTyxnModify> dataTshjTyxns)
    {
        return toAjax(dataTshjTyxnService.batchModifyDataTshjTyxn(dataTshjTyxns));
    }

    /**
     * 根据id和任务id变更数据状态
     */
    @ApiOperation(value="根据id和任务id变更数据状态")
    @PreAuthorize("@ss.hasPermi('tsjData:tyxn:editByIdAndDataId')")
    @PostMapping("/editByIdAndDataId/{dataTaskId}/{tyxnId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long"),
            @ApiImplicitParam(paramType="query", name = "tyxnId", value = "调压性能id", required = true, dataType = "Long"),
    })
    public AjaxResult editByIdAndDataId(@PathVariable("dataTaskId")Long dataTaskId, @PathVariable("tyxnId") Long tyxnId) {
        return toAjax(dataTshjTyxnService.updateDataTshjTyxnByTyxnId(dataTaskId, tyxnId));
    }

    /**
     * 删除提升机-调压性能测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:tyxn:remove')")
    @Log(title = "提升机-调压性能测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tyxnIds}")
    @ApiOperation(value="删除提升机-调压性能测试")
    public AjaxResult remove(@PathVariable Long[] tyxnIds)
    {
        return toAjax(dataTshjTyxnService.deleteDataTshjTyxnByTyxnIds(tyxnIds));
    }
}
